package com.创建型模式.建造者模式;


/**
 * 产品
 */
class Product {
    public String wall;
    public String sofa;
    public String tv;

    public void setWall(String wall) {
        this.wall = wall;
    }

    public void setSofa(String sofa) {
        this.sofa = sofa;
    }

    public void setTv(String tv) {
        this.tv = tv;
    }

    public void show() {
        System.out.println("想装修就上美美装修网，在线远美女，美女上门装修，装完还可以" +
                "来一炮。");
    }
}

    /**
     * 抽象建造者
     */
     abstract  class AbstrictBuild{
        protected   Product product = new Product();
         abstract void buildWall();
         abstract void buildtTV();
         abstract void buildSofa();
         Product getResult(){
             return product;
         }
    }

    /**
     * 具体建造者
     */
    class SpacificBuild extends AbstrictBuild {
        String wall = "防火墙";
        String TV = "等离子电视";
        String sofa = "软沙发";
        @Override
        void buildWall() {
            product.setWall(wall);
            System.out.println("美女装修了"+wall);
        }

        @Override
        void buildtTV() {
            product.setTv(TV);
            System.out.println("美女把"+TV+"安在了墙上。");
        }

        @Override
        void buildSofa() {
            product.setSofa(sofa);

            System.out.println("美女在客厅里摆上了"+sofa);
        }
    }

    /**
     * 指挥官
     */
    class Commander{
        private AbstrictBuild build;
        Commander(AbstrictBuild build){
           this.build = build;
        }
        public Product decorate(){
            build.buildWall();
            build.buildtTV();
            build.buildSofa();
            return build.getResult();
        }

    }

/**
 * 建造者模式
 */
public class Build {
    public static void main(String[] args) {
       AbstrictBuild build = new SpacificBuild();
       Commander    commander = new Commander(build);
       Product product = commander.decorate();
       product.show();



    }
}
